#include "stdafx.h"
#include "CppUnitException.h"

namespace JHCPP{
	namespace CppUnit{
		const std::string CCppUnitException::CPPUNIT_UNKNOWNFILENAME = "<unknown>";
		const int CCppUnitException::CPPUNIT_UNKNOWNLINENUMBER = -1;

		CCppUnitException::CCppUnitException(const CCppUnitException& other) 
		: exception (other)
		{
			m_message         = other.m_message;
			m_lineNumber      = other.m_lineNumber;
			m_data1lineNumber = other.m_data1lineNumber;
			m_data2lineNumber = other.m_data2lineNumber;
			m_fileName        = other.m_fileName;
		}

		CCppUnitException::CCppUnitException (const std::string& message, long lineNumber, const std::string& fileName)
		: m_message(message),
		m_lineNumber(lineNumber),
		m_data1lineNumber(CPPUNIT_UNKNOWNLINENUMBER), 
		m_data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), 
		m_fileName(fileName)
		{
		}

		CCppUnitException::CCppUnitException (const std::string& message, long lineNumber, long data1lineNumber, const std::string& fileName)
		: m_message(message),
		m_lineNumber(lineNumber),
		m_data1lineNumber(data1lineNumber),
		m_data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER),
		m_fileName(fileName)
		{
		}

		CCppUnitException::CCppUnitException (const std::string& message, long lineNumber, long data1lineNumber, long data2lineNumber, const std::string& fileName)
		: m_message(message),
		m_lineNumber(lineNumber),
		m_data1lineNumber(data1lineNumber),
		m_data2lineNumber(data2lineNumber),
		m_fileName(fileName)
		{
		}

		CCppUnitException::~CCppUnitException () throw()
		{
		}

		CCppUnitException& CCppUnitException::operator = (const CCppUnitException& other)
		{
			exception::operator= (other);

			if (&other != this)
			{
				m_message			= other.m_message;
				m_lineNumber		= other.m_lineNumber;
				m_data1lineNumber	= other.m_data1lineNumber;
				m_data2lineNumber	= other.m_data2lineNumber;
				m_fileName			= other.m_fileName;
			}
			return *this;
		}

		const char* CCppUnitException::what() const throw ()
		{
			return m_message.c_str();
		}

		long CCppUnitException::lineNumber() const
		{
			return m_lineNumber; 
		}

		long CCppUnitException::data1LineNumber() const
		{
			return m_data1lineNumber; 
		}

		long CCppUnitException::data2LineNumber() const
		{
			return m_data2lineNumber; 
		}

		const std::string& CCppUnitException::fileName() const
		{
			return m_fileName; 
		}

	}//end of namespace CppUnit
}//end of namespace JHCPP
